﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Configuration;

namespace customer.dao.V2
{
    public class SchemaReaderBuilder
    {

        public SchemaReaderBase GetSR(string db)
        {
            if (ConfigurationManager.ConnectionStrings[db] == null)
                return null;

            var connectionString = ConfigurationManager.ConnectionStrings[db].ConnectionString;
            var providerName = ConfigurationManager.ConnectionStrings[db].ProviderName;

            if (providerName.ToLower().Contains("system.data.sqlclient"))
            {
                return new SqlServerSchemaReader(connectionString);
            }
            else if (providerName.ToLower().Contains("oracle.manageddataaccess.client"))
            {
                return new OracleSchemaReader(connectionString);
            }
            else if (providerName.ToLower().Contains("mysql.data.mysqlclient"))
            {
                return new MySqlSchemaReader(connectionString);
            }

            return null;
        }


    }
}
